package com.ruoyi.web.controller.project;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.AccountAnnal;
import com.ruoyi.project.service.IAccountAnnalService;
import com.ruoyi.web.core.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;

/**
 * 账户变动记录 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-11-01
 */
@Controller
@RequestMapping("/project/accountAnnal")
public class AccountAnnalController extends BaseController
{
    private String prefix = "project/accountAnnal";
	
	@Autowired
	private IAccountAnnalService accountAnnalService;
	
	@RequiresPermissions("project:accountAnnal:view")
	@GetMapping()
	public String accountAnnal()
	{
	    return prefix + "/accountAnnal";
	}
	
	/**
	 * 查询账户变动记录列表
	 */
	@RequiresPermissions("project:accountAnnal:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AccountAnnal accountAnnal)
	{
		startPage();
        List<AccountAnnal> list = accountAnnalService.selectAccountAnnalList(accountAnnal);
		return getDataTable(list);
	}
	
	/**
	 * 新增账户变动记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存账户变动记录
	 */
	@RequiresPermissions("project:accountAnnal:add")
	@Log(title = "账户变动记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AccountAnnal accountAnnal)
	{		
		return toAjax(accountAnnalService.insertAccountAnnal(accountAnnal));
	}

	/**
	 * 修改账户变动记录
	 */
	@GetMapping("/edit/{accountAnnalId}")
	public String edit(@PathVariable("accountAnnalId") Long accountAnnalId, ModelMap mmap)
	{
		AccountAnnal accountAnnal = accountAnnalService.selectAccountAnnalById(accountAnnalId);
		mmap.put("accountAnnal", accountAnnal);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存账户变动记录
	 */
	@RequiresPermissions("project:accountAnnal:edit")
	@Log(title = "账户变动记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AccountAnnal accountAnnal)
	{		
		return toAjax(accountAnnalService.updateAccountAnnal(accountAnnal));
	}
	
	/**
	 * 删除账户变动记录
	 */
	@RequiresPermissions("project:accountAnnal:remove")
	@Log(title = "账户变动记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(accountAnnalService.deleteAccountAnnalByIds(ids));
	}
	
}
